import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';

const host = 'localhost';
const port = 16250;

const TARGET_URL = 'http://127.0.0.1:16250/';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  devServer: {
    allowedHosts: 'all',
    host,
    port: port,
    open: false,
    proxy: {
      [TARGET_URL]: {
        target: TARGET_URL, // 本地
        changeOrigin: true,
        pathRewrite: {
          [`^${TARGET_URL}`]: '/api',
        },
      },
    },
    client: {
      webSocketURL: {
        hostname: host,
        port,
      },
      overlay: false,
    },
  },
})
